package com.etone.fileServer.controller;

import com.etone.fileServer.dto.compress.CompressDTO;
import com.etone.fileServer.dto.compress.DecompressDTO;
import com.etone.fileServer.service.CompressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: sovy
 * @date: 2020/11/4
 * @description:
 */
@AllArgsConstructor
@RestController
@Api(tags = "文件压缩与解压管理", value = "FileCompressController")
public class CompressController {
    private CompressService compressService;

    @ApiOperation(value = "压缩文件《完》")
    @PostMapping("/compress")
    private void compress(
            @ApiParam(value = "时间戳") @RequestParam Long timestamp,
            @ApiParam(value = "密文") @RequestParam String sign,
            @ApiParam(value = "压缩信息") @RequestBody @Validated CompressDTO compressDTO
    ) {
        compressService.compress(compressDTO, timestamp, sign);
    }

    @ApiOperation(value = "解压文件《完》")
    @PostMapping("/decompress")
    private void decompress(
            @ApiParam(value = "时间戳") @RequestParam Long timestamp,
            @ApiParam(value = "密文") @RequestParam String sign,
            @ApiParam(value = "解压信息") @RequestBody @Validated DecompressDTO decompressDTO
    ) {
        compressService.decompress(decompressDTO, timestamp, sign);
    }
}
